package com.sdgakj.utils;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

@Component
public class InitIndexCondition {
	
	private static Map<String, Object> keyMap = new HashMap<String, Object>();
	private static Map<String, Object> conditionMap = new HashMap<String, Object>();
	private static boolean TAG = true;
	private static final String SORTNAME = "orderno";
	private static final String SORTTYPE = "desc";
	
	@PostConstruct
	public void init() {
		if (keyMap == null) {
			keyMap = new HashMap<String, Object>();
		}
		if (keyMap.isEmpty()) {
//			initConditionProvince(SORTNAME, SORTTYPE);
		}
		/** 2016年3月1日14:29:46 注释,放到了condition中 */
		// List<ShtCity> cityList = areaService.getCitysByTruck();
		// keyMap.put("cityKey", cityList);
	}
	
	public void initCondition(String sortname, String sorttype) {
		//List<TruckBrand> brandList = brandService.findByTagOrder2App();
		// 来源
		/** init()方法注释掉后，放到了这里 */
//		List<ShtCity> cityList = areaService.getCitysByTruck();
//		List<ShtCity> purchasecityList = areaService.getCitysByPurchaseTruck();
//		List<ShtCity> wxcityList = areaService.getCitysBySeries();
//		conditionMap.put("cityKey", cityList);
//		conditionMap.put("cargos", cargos);
//		conditionMap.put("trailers", trailers);
		/*****/
		
/*        List<JSFShop> shopList = jSFShopService.getAllJSFShop("0");
        List<String> list = new ArrayList<String>();
        if(shopList != null && shopList.size() > 0)
        {
            for(JSFShop shop : shopList)
            {
                String cityid = shop.getCityid();
                if(StringUtils.isNotBlank(cityid))
                {
                    list.add(cityid);
                }
            }
        }*/
		
//		List<ShtCityKey> cityKeys = areaService.getAllCityKey();
//		List<CityKey> nameList = new ArrayList<CityKey>();
//		for (ShtCityKey key : cityKeys) {
//			CityKey ck = new CityKey();
//			ck.setName(key.getName());
//			nameList.add(ck);
//		}
	}
	

//	public void initConditionProvince(String sortname, String sorttype) {
//		// 省SORTNAME
//		PinYinSort.ProvinceListSort(provinceList);
//		keyMap.put("provinceKey", provinceList);
//	}

	public Map<String, Object> getKeymap(String sortName, String sortType, boolean tag) {
		/***2016年12月8日15:04:27之前***/
/*        if(!sortName.equals("orderno") || !sortType.equals("desc") && tag == TAG)
        {
            // List<ShtCity> cityList = areaService.getCitysByTruck();
            // keyMap.put("cityKey", cityList);
            initCondition(sortName, sortType);
        }
        else
        {
            // init();
            // List<ShtCity> cityList = areaService.getCitysByTruck();
            // keyMap.put("cityKey", cityList);
            initCondition(sortName, sortType);
        }*/
		/***end  2016年12月8日15:04:48**/
		if (conditionMap.isEmpty() || conditionMap.size() == 0 || conditionMap == null) {
			initCondition(sortName, sortType);
		}
		return conditionMap;
	}
	
//	static class CityKey {
//
//		private String name = "";
//
//		public String getName() {
//			return name;
//		}
//
//		public void setName(String name) {
//			this.name = name;
//		}
//
//	}
	
}
